package com.bzframework.core.response.exception;

import com.bzframework.core.response.ErrorCode;

/**
 * 无权限
 */
public class NoAuthorizationException extends RuntimeException {

    /**
     * 错误码
     */
    private final int code;

    public NoAuthorizationException(int code, String message) {
        super(message);
        this.code = code;
    }

    public NoAuthorizationException() {
        super(ErrorCode.NO_AUTHORIZATION.getMessage());
        this.code = ErrorCode.NO_AUTHORIZATION.getCode();
    }

    public NoAuthorizationException(ErrorCode errorCode) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
    }

    public NoAuthorizationException(ErrorCode errorCode, String message) {
        super(message);
        this.code = errorCode.getCode();
    }

    public int getCode() {
        return code;
    }
}
